package com.herui.ota.controller;

import com.herui.ota.exception.ServiceException;
import com.mlnx.common.entity.Response;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * Created by amanda.shan on 2019/7/1.
 */
@ControllerAdvice
@ResponseBody
public class WebExceptionHandle {

    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(ServiceException.class)
    public Response handleHttpUserException(ServiceException e) {
        return new Response(e.getCode(), e.getDescribe());
    }

}
